package cn.xo68.metadata.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import cn.xo68.boot.web.common.ResponseResultConstants;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageInfo;
import cn.xo68.metadata.entity.MetadataTable;
import cn.xo68.metadata.service.MetadataTableService;



/** 
 * MetadataTable controller
 * @author wuyy(16349023@qq.com)
 * @date 2020年03月12日 11:44:16
 *
 */
 @Api(value = "MetadataTable",tags = {"MetadataTable"})
@RequestMapping("/MetadataTable")
@Slf4j
@RestController
public class MetadataTableController{

    @Autowired
    private MetadataTableService metadataTableService;

    @ApiOperation(value="详情")
	@GetMapping("/detail/{tableId}")
    public MetadataTable detail(@PathVariable(name="tableId") Integer tableId) {
        return metadataTableService.find(tableId);
    }
    
    @ApiOperation(value="翻页列表")
    @GetMapping("/list")
    public PageInfo<MetadataTable> list(@RequestParam(name="pageIndex",defaultValue="1") int pageIndex,@RequestParam(name="pageSize",defaultValue="10") int pageSize){
        return metadataTableService.list(pageIndex, pageSize);
    }
	
    @ApiOperation(value="创建")
	@PostMapping
    public MetadataTable add(@RequestBody MetadataTable entity ) {
        return metadataTableService.insert(entity);
    }
	
    @ApiOperation(value="删除")
	@DeleteMapping
	public String delete(@RequestParam(name="id") Integer id) {
	    metadataTableService.delete(id);
        return ResponseResultConstants.RESPONSE_DATA_SUCCESS;
	}
	
    @ApiOperation(value="更新")
	@PutMapping
	public MetadataTable update(@RequestBody MetadataTable entity) {
	    return metadataTableService.update(entity);
	}
}